package com.hudson.plugin;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Builds entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "builds", catalog = "reportdb")
public class Builds implements java.io.Serializable {

    // Fields

    private Integer id;
    private Projects projects;
    private Integer buildNum;
    private String causeAction;
    private String author;
    private String result;
    private Integer duration;
    private String buildOn;
    private Integer failCount;
    private Integer skipCount;
    private Integer totalCount;
    private Timestamp buildDate;
    private Set<Coverage> coverages = new HashSet<Coverage>(0);

    // Constructors

    /**
     * default constructor
     */
    public Builds() {
    }

    /**
     * full constructor
     */
    public Builds(Projects projects, Integer buildNum, String causeAction,
                  String author, String result, Integer duration, String buildOn,
                  Integer failCount, Integer skipCount, Integer totalCount,
                  Timestamp buildDate, Set<Coverage> coverages) {
        this.projects = projects;
        this.buildNum = buildNum;
        this.causeAction = causeAction;
        this.author = author;
        this.result = result;
        this.duration = duration;
        this.buildOn = buildOn;
        this.failCount = failCount;
        this.skipCount = skipCount;
        this.totalCount = totalCount;
        this.buildDate = buildDate;
        this.coverages = coverages;
    }

    // Property accessors
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "project_id")
    public Projects getProjects() {
        return this.projects;
    }

    public void setProjects(Projects projects) {
        this.projects = projects;
    }

    @Column(name = "build_num")
    public Integer getBuildNum() {
        return this.buildNum;
    }

    public void setBuildNum(Integer buildNum) {
        this.buildNum = buildNum;
    }

    @Column(name = "cause_action", length = 64)
    public String getCauseAction() {
        return this.causeAction;
    }

    public void setCauseAction(String causeAction) {
        this.causeAction = causeAction;
    }

    @Column(name = "author", length = 64)
    public String getAuthor() {
        return this.author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    @Column(name = "result", length = 12)
    public String getResult() {
        return this.result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    @Column(name = "duration")
    public Integer getDuration() {
        return this.duration;
    }

    public void setDuration(Integer duration) {
        this.duration = duration;
    }

    @Column(name = "build_on", length = 256)
    public String getBuildOn() {
        return this.buildOn;
    }

    public void setBuildOn(String buildOn) {
        this.buildOn = buildOn;
    }

    @Column(name = "failCount")
    public Integer getFailCount() {
        return this.failCount;
    }

    public void setFailCount(Integer failCount) {
        this.failCount = failCount;
    }

    @Column(name = "skipCount")
    public Integer getSkipCount() {
        return this.skipCount;
    }

    public void setSkipCount(Integer skipCount) {
        this.skipCount = skipCount;
    }

    @Column(name = "totalCount")
    public Integer getTotalCount() {
        return this.totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    @Column(name = "build_date", length = 19)
    public Timestamp getBuildDate() {
        return this.buildDate;
    }

    public void setBuildDate(Timestamp buildDate) {
        this.buildDate = buildDate;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "builds")
    public Set<Coverage> getCoverages() {
        return this.coverages;
    }

    public void setCoverages(Set<Coverage> coverages) {
        this.coverages = coverages;
    }

}